package com.example.gallery;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.board.R;


public class BoardAdapter extends ArrayAdapter<BoardDTO>{
	ArrayList<BoardDTO> list;
	final static String TAG = "BoardAdapter";
	
	
	public BoardAdapter(Context context, int resource, ArrayList<BoardDTO> list) {
		super(context, resource, list);
		this.list = list;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if(v == null){
			LayoutInflater vi = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

			v = vi.inflate(R.layout.row, null);
		}
		notifyDataSetChanged();
		BoardDTO board = list.get(position);
		notifyDataSetChanged();
//		Log.i(TAG, "�Խñ� �� �� : "+list.size());	// ����Ʈ ����ŭ call
		/*list.notify();
		list.notifyAll();*/
		if(board != null){
			TextView tv_no = (TextView) v.findViewById(R.id.tv_no);
			TextView tv_title = (TextView) v.findViewById(R.id.tv_title);
			TextView tv_id = (TextView) v.findViewById(R.id.tv_id);
			TextView tv_date = (TextView) v.findViewById(R.id.tv_date);
			
			tv_no.setText(board.getNO()+"");
			tv_title.setText(board.getTITLE());
			tv_id.setText(board.getID());
			tv_date.setText(board.getDATE());
		}
		return v;
	}
	

}
